<template>
  <Spin :spinning="loading" tip="Loading...">
  <div>
    <!-- table -->
    <BreakSpace label="工单及车辆信息" :containerStyle="{ marginBottom: '10px' }" />
    <FormPanel ref="formPanel1" :list="formList" :cols="4" :formType="'add'" labelWidth="100" :isSubmitBtn="false" @formChange="formChangeHandle1" />
    <BaseDialog :visible.sync="vinSelect" :title="'VIN选择'" width="850px" destroyOnClose :containerStyle="{height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px'}">
      <SelectVin @close="vinClose" @save="selectVinSave"></SelectVin>
    </BaseDialog>
    <BaseDialog :visible.sync="repairOrder" :title="'工单选择'" width="850px" destroyOnClose :containerStyle="{height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px'}">
      <SelectRepairOrder @close="repairOrderClose" @save="repairOrderSave"></SelectRepairOrder>
    </BaseDialog>
    <BaseDialog :visible.sync="mainDamagePart" :title="'主损件选择'" width="850px" destroyOnClose :containerStyle="{height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px'}">
      <SelectMainDamagePart @close="mainDamagePartClose" @save="mainDamagePartSave"></SelectMainDamagePart>
    </BaseDialog>
    <BaseDialog :visible.sync="faultAppearance" :title="'故障现象选择'" width="850px" destroyOnClose :containerStyle="{height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px'}">
      <SelectFaultAppear @close="faultAppearClose" @save="faultAppearSave"></SelectFaultAppear>
    </BaseDialog>
    <BaseDialog :visible.sync="faultReason" :title="'故障原因选择'" width="850px" destroyOnClose :containerStyle="{height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px'}">
      <SelectFaultReason @close="faultReasonClose" @save="faultReasonSave"></SelectFaultReason>
    </BaseDialog>
<!--    <BaseDialog :visible.sync="rescueFlag" :title="'救援单选择'" width="850px" destroyOnClose :containerStyle="{height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px'}">-->
<!--      <SelectRescue @close="rescueClose" @save="rescueSave"></SelectRescue>-->
<!--    </BaseDialog>-->
    <BaseDialog :visible.sync="RepairItemListaddflag" :title="'维修项目列表新增'" width="850px" destroyOnClose :containerStyle="{height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px'}">
      <RepairItemList @close="RepairItemListClose" @save="RepairItemListSave" :rowDate="rowDate"></RepairItemList>
    </BaseDialog>
    <BaseDialog :visible.sync="PartTakeOnlistaddflag" :title="'配件换上件列表新增'" width="850px" destroyOnClose :containerStyle="{height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px'}">
      <PartSelect @close="partTakeOnClose" @save="partTakeOnSave" :rowDate="rowDate"></PartSelect>
    </BaseDialog>

    <BaseDialog :visible.sync="appendItemlistaddflag" :title="'附加项目列表新增'" width="850px" destroyOnClose :containerStyle="{height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px'}">
      <appendItemlist @close="appendItemClose" @save="appendItemSave"></appendItemlist>
    </BaseDialog>
    <BaseDialog :visible.sync="isvideo" :title="'视频预览'" destroyOnClose :containerStyle="{ height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px' }">
      <videos @close="dealercloseHandler" :src="src"/>
    </BaseDialog>
    <div style="padding-top: 1rem;"></div>
    <BreakSpace label="索赔信息" :containerStyle="{ marginBottom: '10px' }" />
    <FormPanel ref="formPanel2" :list="formList1" :cols="4" :formType="'add'" labelWidth="110" :isSubmitBtn="false" @formChange="formChangeHandle2" />
    <div style="padding-top: 1rem;"></div>

    <BreakSpace label="维修项目列表" :containerStyle="{ marginBottom: '10px' }" />
    <FilterTable
      ref="repairItemtable"
      :columns="columns"
      :params="fetchParams"
      :datakey="'items'"
      :onColumnsChange="columns => (this.columns = columns)"
      :onRowSelectChange="selectChange"
      :is-select-column="false"
      :isPagination = false
      height="auto"
    >
      <!-- 维修项目列表新增 -->
<!--      <template slot="controls" slot-scope="props">-->
<!--        <multiuse-button size="small" type="primary" icon="el-icon-plus" @click="RepairItemListadd()">添加</multiuse-button>-->
<!--      </template>-->
    </FilterTable>
    <div style="padding-top: 1rem;"></div>
    <BreakSpace label="配件换上件列表" :containerStyle="{ marginBottom: '10px' }" />
    <FilterTable
      ref="partTakeOntable"
      :columns="columns1"
      :params="fetchParams"
      :datakey="'items'"
      :onColumnsChange="columns1 => (this.columns1 = columns1)"
      :onRowSelectChange="selectChange"
      :is-select-column="false"
      :isPagination = false
      height="auto"
    >
<!--      <template slot="controls" slot-scope="props">-->
<!--        <multiuse-button size="small" type="primary" icon="el-icon-plus" @click="partTakeOnadd()">添加</multiuse-button>-->
<!--      </template>-->
    </FilterTable>
    <div style="padding-top: 1rem;"></div>
    <BreakSpace label="配件换下件列表" :containerStyle="{ marginBottom: '10px' }" />
    <FilterTable
      ref="table2"
      :columns="columnspartTakeOff"
      :params="fetchParams"
      :dataSource="takeOffPartdataList"
      :datakey="'items'"
      :onColumnsChange="(columnspartTakeOff) => (this.columnspartTakeOff = columnspartTakeOff)"
      :onRowSelectChange="selectChange"
      selectionType="single"
      :isSelectColumn="false"
      :isPagination="false"
      height="auto"
    >
<!--      <template slot="controls" slot-scope="props">-->
<!--        <multiuse-button size="small" type="primary" icon="el-icon-plus" @click="partTakeOffadd()">添加</multiuse-button>-->
<!--      </template>-->
    </FilterTable>
    <BreakSpace label="附加项目列表" :containerStyle="{ marginBottom: '10px' }" />
    <FilterTable
      ref="appendItemtable"
      :columns="columnsAppendItem"
      :params="fetchParams"
      :datakey="'items'"
      :onColumnsChange="columnsAppendItem => (this.columnsAppendItem = columnsAppendItem)"
      :onRowSelectChange="selectChange"
      :is-select-column="false"
      :isPagination = false
      height="auto"
      :onCellChange="changeCells1"
    >
<!--      <template slot="controls" slot-scope="props">-->
<!--        <multiuse-button size="small" type="primary" icon="el-icon-plus" @click="appendItemadd()">添加</multiuse-button>-->
<!--      </template>-->
    </FilterTable>
    <div style="padding-top: 1rem;"></div>
    <BreakSpace label="费用信息" :containerStyle="{ marginBottom: '10px' }" />
    <FormPanel ref="formPanel3" :list="feiyongformList" :cols="4" :formType="'add'" labelWidth="110" :isSubmitBtn="false" @formChange="formChangeHandle3" />
    <div style="padding-top: 1rem;"></div>
    <LazyLoadTab v-model="activeName" :tabMenus="menus" :destroyOnClose="true"></LazyLoadTab>
    <div style="padding-top: 3rem;"></div>
    <div style="padding-top: 3rem;"></div>
    <div
      :style="{
        position: 'absolute',
        left: 0,
        bottom: 0,
        right: 0,
        zIndex: 9,
        borderTop: '1px solid #e9e9e9',
        padding: '10px 20px',
        background: '#fff',
        textAlign: 'right'
      }"
    >

      <multiuse-button @click="closeDialog">关 闭</multiuse-button>
      <BaseDialog :title="'上传附件'" :visible.sync="upVisible" destroyOnClose>
        <uploadFile :rowData="uploadDate" @close="upVisible = false" @save="saveFile"></uploadFile>
      </BaseDialog>
    </div>
  </div>
  </Spin>
</template>
<script>
  import { editSave, quyRpPreAuth, getSupplierList, cmsClaimTypeStr} from '@/api/claim/dealer/AuthQueryDealer';
  import { queryRepairVehicleList } from '@/api/repair/common';
  import { isFormEmpty } from '@/utils/index';
  import { dictionary } from '@/utils/dictMixin';
  import { getRoLogList } from '@/api/claim/dealer/ClaimApplication/index';
  import videos from '@/pages/claimDemage/BasicData/AuthApplication/videos.vue'
  import moment from 'moment';
  import uploadFile from './uploadFile.vue';
  export default {
     mixins: [dictionary],
    props: ['type', 'rowData'],
    components: {
      uploadFile,
      videos
    },
    data() {
      return {
        uploadDate: {},
        upVisible: false,
        form: {
          fileList: []
        },
        src:null,
        list: [],
        isvideo:false,
        syncList: [],
        columnsFile: this.createdTable(),
        loading: false,
        fileList: [],
        saveData: {}, //保存对象
        saveData1: null,
        saveData2: null,
        saveData3: null,
        partId: null,
        supId: null,
        saveFlag: 0,
        vinSelect: false,
        authNo: null,
        faId: null,
        frId: null,
        addAmount: null,
        supCode: null,
        isDeleted: null,
        jiuyuandanFlag: false,
        faultAppearance: null,
        labourAmount: null,
        partAmount: null,
        modelId: null,
        modelCode: null,
        outId: null,
        outName: null,
        dataList: [],
        dataList1: [],
        repairItemdataList: [],
        partTakeOndataList: [],
        partTakeOffdataList: [],
        appendItemdataList: [],
        takeOffPartdataList:[],
        visible: false,
        visibleDrawer: false,
        appendItemCloselistaddflag: false,
        RepairItemListaddflag: false,
        PartTakeOnlistaddflag: false,
        appendItemlistaddflag: false,
        partTakeOfflistaddflag:false,
        collapse: false,
        zifeigongdanFlag: false,
        repairOrder: false,
        faultReason: false,
        mainDamagePart: false,
        guzhangxianxiangdaima: false,
        infoId: null,
        // topFilterInit: this.topFilterInitFun(),
        flterValue: {}, //参数
        columns: this.creatHeader(),
        columns1: this.creatHeader1(),
        columnsAppendItem: this.columnsAppendItem1(),
        columnspartTakeOff: this.columnspartTakeOffFn(),
        // fetchApi: getUser,
        fetchParams: {}, //ipa 接口
        selectedRows: [], //选中经销商
        hejifeiyong: 0.0,
        gongshifeiyong: 0.0,
        peijianfeiyong: 0.0,
        sumfujiafeiyongz: 0,
        sumweixiufeiyongz: 0,
        partAmountsumz: 0,
        sumfujiafeiyong: 0,
        sumPeiJianFeiYong: 0,
        fujiaxiangmufeiyong: 0.0,

        formList: this.createFormList(),
        formList1: this.createFormList1(),
        feiyongformList: this.feiyongformList1(),
        activeName: '审核记录',
        menus: [
           {
            title: '审核记录',
            path: 'claimDemage/BasicData/AuthApplication/historyForEdit/checkList',
            params: {
              authId: this.rowData.authId
            }
          },
        //   {
        //     title: '维修历史',
        //     path: 'claimDemage/BasicData/AuthApplication/jiLuAndLiShiForEdit/weixiulishi',
        //     params: {
        //       vin: this.rowData.vin
        //     }
        //   },
        //   {
        //     title: '索赔历史',
        //     path: 'claimDemage/BasicData/AuthApplication/jiLuAndLiShiForEdit/suopeilishi',
        //     params: {
        //       vin: this.rowData.vin
        //     }
        //   },
        //   {
        //     title: '变更记录',
        //     path: 'claimDemage/BasicData/AuthApplication/jiLuAndLiShiForEdit/biangengjilu',
        //     params: {
        //       authId: this.rowData.authId
        //     }
        //   },
        //   {
        //     title: '预授权历史',
        //     path: 'claimDemage/BasicData/AuthCheck/jiLuAndLiShiForEdit/preAuth',
        //     // disabled: true,
        //     params: {
        //       vin:this.rowData.vin,
        //     }
        // },
        ]
      };
    },
    created() {
      loading: true;
      this.Sum();
      this.getAuthTypeStr();
      //this.getSupplierListStr();
      this.chuqi();
      this.getAuthListByauthNo(this.rowData.authId);
      if(this.rowData.vin){
         this.queryRepairVehicleMessage(this.rowData.vin);}
      loading: false;
    },
    async mounted() {
      console.log('************321');
      //console.log(this.$refs.appendItemtable.$refs.pageTable.GET_UPDATE_ROWS());

     // this.selectRowById(this.rowData.roNo);
    },
    methods: {
      dealercloseHandler(){
        this.isvideo = false;
      },
      // 上传成功回调
      successHandler(val) {
        let json = JSON.parse(JSON.stringify(val));
        let data = {};
        data.createdAt = moment().format('YYYY-MM-DD HH:mm:ss');
        data.title = json[json.length - 1].name;
        data.fileUrl = json[json.length - 1].url;
        this.$refs.fileTable.$refs.pageTable.EXECUTE_INSERT(data);
      },
      video(val){
        this.isvideo = true;
        this.src = val.fileUrl;
      },
      delVideo(val){
        console.log("#@!#!",val)
        this.$refs.fileTable.$refs.pageTable.EXECUTE_DELETE([val]);
      },
      async queryRepairVehicleMessage(val) {
        //掉外部接口 vin 取得工单信息
        let res = await queryRepairVehicleList({ vin: val });
        //是否特殊车
        // let isSpecialResult = await translateByVinAndModelCode({vin:res.data.rows[0].VIN,modelCode: res.data.rows[0].MODEL_CODE,customerType: res.data.rows[0].BUSINESS_KIND});
        this.formList.map(x => {
          // //是否特殊车
          // if ('isSpecial' == x.fieldName) {
          //   x.initialValue =Number(isSpecialResult.data.isSpecial);
          // }
          //车主姓名
          if ('customerName' == x.fieldName) {
            x.initialValue =res.data.rows[0].OWNER_NAME;
          }
          //车主手机号
          if ('customerPhone' == x.fieldName) {
            x.initialValue =res.data.rows[0].MOBILE;
          }
          //车辆用途
          if ('useType' == x.fieldName) {
            x.initialValue =this.createDictText(res.data.rows[0].VEHICLE_PURPOSE, '1511');
          }
          //用户属性
          if ('customerType' == x.fieldName) {
            x.initialValue =this.createDictText(res.data.rows[0].BUSINESS_KIND, '1511');

            // x.initialValue =Number(isSpecialResult.data.customerType)
            // x.initialValue =this.createDictText(isSpecialResult.data.customerType, '5584');
          }
        });
      },
      //预授权类型下拉
      async getAuthTypeStr() {
        const res1 = await cmsClaimTypeStr({ type: 5508 });
        if (res1.resultCode == 200) {
          this.formList1.find(x => x.fieldName == 'authType').itemList = res1.data.map(y => ({ text: y.codeCnDesc, value: y.codeId }));
        }
        const res2 = await cmsClaimTypeStr({ type: 5504 });
        if (res2.resultCode == 200) {
          this.formList1.find(x => x.fieldName == 'authSub').itemList = res2.data.map(y => ({ text: y.codeCnDesc, value: y.codeId }));
        }
      },
      //供应商下拉
      async getSupplierListStr() {
        const res = await getSupplierList();
        if (res.resultCode == 200) {
          this.formList1.find(x => x.fieldName == 'supName').initialValue = '';
          this.formList1.find(x => x.fieldName == 'supName').itemList = res.data.map(y => ({ text: y.supName, value: y.supCode }));
        }
      },sumAmount() {
        let sum = 0;
        this.$refs.appendItemtable.$refs.pageTable.list.map(x => {
          sum += Number(x.addAmount);
        });

        this.$refs.repairItemtable.$refs.pageTable.list.map(x => {
          sum += Number(x.cmsClaimAmount);
        });

        this.$refs.partTakeOntable.$refs.pageTable.list.map(x => {
          sum += Number(x.cmsClaimPrice);
        });

        this.feiyongformList.map(x => {
          if('sumAmount' == x.fieldName) {
            x.initialValue = sum;
          }
        });

      },
      async getAuthListByauthNo(authNo) {
        let res = await quyRpPreAuth(authNo);
        let data = res.data;
        //临时属性
        this.partId = data.partId; //主损件id
        this.supId = data.supId; //供应商ID
        this.supCode = data.supCode; //供应商Code
        this.faultAppear = data.faultAppear; //故障现象
        this.labourAmount = data.labourAmount; //工时费用
        this.partAmount = data.partAmount; //配件费用
        this.modelId = data.modelId; //车型id
        this.modelCode = data.modelCode; //车型Code
        this.faId = data.faId; //故障现象主键
        this.isDeleted = data.isDeleted;
        this.addAmount = data.addAmount;
        this.sumfujiafeiyongz = data.addAmount;
        this.sumweixiufeiyongz = data.labourAmount;
        this.partAmountsumz = data.partAmount;
        // this.authNo = data.authNo;
        console.log(777777777);
        console.log(data.outId);
        this.outId = data.outId;
        this.outCode = data.outCode;
        // this.menus[1].params.vin = data.vin;
        this.frId = data.frId; //故障原因主键
        if(data.saleDate){
          data.saleDate = moment(data.saleDate).format('YYYY-MM-DD');
        }
        if(data.repairBeginDate){
          data.repairBeginDate = moment(data.repairBeginDate).format('YYYY-MM-DD');
        }
        if(data.repairEndDate){
          data.repairEndDate = moment(data.repairEndDate).format('YYYY-MM-DD');
        }
        // this.prodDate = data.prodDate;
        let wxLog = await getRoLogList({vin:data.vin,current:1,limit:100,currentPage:1,pageNum:1,pageSize: 100,size: 100});
        if(wxLog.data.rows.length>=2){
          data.lastDrive = wxLog.data.rows[wxLog.data.rows.length-2].IN_MILEAGE;
        }else{
          data.lastDrive = 0
        }
        console.log(22 / 222);
        console.log(this.outId);
        console.log(data.outId);
        console.log(22 / 222);
        //为3个form赋值
        for (let i in data) {
          this.formList.map(y => {
            if (i == y.fieldName) {
              y.initialValue = data[i];
            }
          });
          this.formList1.map(y => {
            if (i == y.fieldName) {
              y.initialValue = data[i];
            }
            // if (y.fieldName == 'outCode') {
            //   y.initialValue = data['outNo'];
            // }
            if ('authType' == y.fieldName) {

              y.initialValue = data.authType;

              if (y.initialValue  == 55081003) {
                this.formList1.map(y => {
                  if (y.fieldName == 'authSub') {
                    y.hidden = false;
                    y.initialValue = data.authSub;
                  }
                })
              } else{
                this.formList1.map(y => {
                  if (y.fieldName == 'authSub') {
                    y.hidden = true;
                    y.initialValue = undefined;
                  }
                })

              }
            }

          });
          this.feiyongformList.map(y => {
            if (i == y.fieldName) {
              y.initialValue = data[i];
            }
          });
        }
        //为table赋值
        // for (let i in data.fileList) {
        //   if(data.fileList[i].type==55041001) {
        //     this.formList1.find(x => x.fieldName == 'wayPicture').initialValue =  [{url : data.fileList[i].fileUrl,name : data.fileList[i].title}];
        //   }else if(data.fileList[i].type==55041002) {
        //     this.formList1.find(x => x.fieldName == 'wayPicture1').initialValue = [{url : data.fileList[i].fileUrl,name : data.fileList[i].title}];
        //   }else if(data.fileList[i].type==55041003) {
        //     this.formList1.find(x => x.fieldName == 'wayPicture2').initialValue = [{url : data.fileList[i].fileUrl,name : data.fileList[i].title}];
        //   }else if(data.fileList[i].type==55041004) {
        //     this.formList1.find(x => x.fieldName == 'wayPicture3').initialValue = [{url : data.fileList[i].fileUrl,name : data.fileList[i].title}];
        //   }else if(data.fileList[i].type==55041005) {
        //     this.formList1.find(x => x.fieldName == 'wayPicture4').initialValue = [{url : data.fileList[i].fileUrl,name : data.fileList[i].title}];
        //   }else if(data.fileList[i].type==55041006) {
        //     this.formList1.find(x => x.fieldName == 'wayPicture5').initialValue = [{url : data.fileList[i].fileUrl,name : data.fileList[i].title}];
        //   }
        //
        // }
        let newFile = [];
        for(let i in data.fileList){
          if(data.fileList[i].type==null){
            newFile.push(res.data.fileList[i])
          }
        }
        this.$refs.fileTable.$refs.pageTable.EXECUTE_INSERT(newFile);
        if (200 == res.resultCode) {
          let data = res.data;
          if (isFormEmpty(data)) {
            data = {};
          }
          let records = data.labourList;
          if (isFormEmpty(records)) {
            records = [];
          }
          if (!isFormEmpty(records)) {
            records.map(x => {
              x.cmsClaimType='索赔';
            });
          }
          this.$refs.repairItemtable.$refs.pageTable.EXECUTE_INSERT(records);
          let records1 = data.addList;
          if (isFormEmpty(records1)) {
            records1 = [];
          }
          this.$refs.appendItemtable.$refs.pageTable.EXECUTE_INSERT(records1);
        }
        let records3 = data.partRList;
        if (isFormEmpty(records3)) {
          records3 = [];
        }
        this.$refs.partTakeOntable.$refs.pageTable.EXECUTE_INSERT(records3);

        let records2 = data.partList;
        if (isFormEmpty(records2)) {
          records2 = [];
        }
        this.$refs.table2.$refs.pageTable.EXECUTE_INSERT(records2);
        console.info(res);
      },
      //
      // async selectRowById(val) {
      //   //掉外部接口 工单号 取得工单信息
      //   let res = await quyRomessage({ roNo: val });
      //   let data = res.data;
      //   for (let i in data) {
      //     this.formList.map(y => {
      //       if (i == y.fieldName) {
      //         y.initialValue = data[i];
      //       }
      //     });
      //   }
      // },
      async Sum() {
        console.log(99999);
        console.log(this.sumfujiafeiyong);
      },
      async chuqi() {
        // const res1 = await getPartType({ type: 5532 });
        // if (res1.resultCode == 200) {
        //   this.formList.find(x => x.fieldName == 'isSpecial').itemList = res1.data.map(y => ({ text: y.codeCnDesc, value: y.codeId }));
        // }
        // const res3 = await getPartType({ type: 5584 });
        // if (res3.resultCode == 200) {
        //   this.formList.find(x => x.fieldName == 'customerType').itemList = res3.data.map(y => ({ text: y.codeCnDesc, value: y.codeId }));
        // }
        // const res = await getPartType({ type: 5503 });
        // if (res.resultCode == 200) {
        //   this.formList.find(x => x.fieldName == 'authStatus').initialValue = '';
        //   this.formList.find(x => x.fieldName == 'authStatus').itemList = res.data.map(y => ({ text: y.codeCnDesc, value: y.codeId }));
        // }
      },
      saveFile(obj){
        let list = this.$refs.appendItemtable.$refs.pageTable.list;
        list.find(x => x.addCode == obj.addCode).addFiles = obj.length==0 ? []:obj;
        this.upVisible = false;
      },
      editFile(row){
        this.upVisible = true;
        this.uploadDate = row;
        this.uploadDate.authId = this.rowData.authId;
      },
      formChangeHandle1(val) {
        console.log(val);
        this.saveData1 = val;
      },
      formChangeHandle2(val) {
        console.log(val);
        this.saveData2 = val;
      },
      formChangeHandle3(val) {
        console.log(val);
        this.saveData3 = val;
      },
      //搜索获取数据
      changeHandle(val) {
        this.fetchParams = val;
        console.log(val);
      },
      //选中
      selectChange(rows) {
        this.selectedRows = rows;
        console.log(this.selectedRows);
      },
      //保存
      async saveDialog() {
        this.$refs.formPanel1.SUBMIT_FORM();
        this.$refs.formPanel2.SUBMIT_FORM();
        this.$refs.formPanel3.SUBMIT_FORM();

        let arr = [];
        this.$refs.appendItemtable.$refs.pageTable.list.map(x => {
          arr.push(x);
        });
        console.log(arr);
        let arr2 = [];
        this.$refs.partTakeOntable.$refs.pageTable.list.map(x => {
          arr2.push(x);
        });
        console.log(arr2);

        let arr3 = [];
        this.$refs.repairItemtable.$refs.pageTable.list.map(x => {
          arr3.push(x);
        });
        console.log(arr3);

        //维修项目
        this.saveData.labourList = arr3;
        //换上件
        this.saveData.partRList = arr2;
        //换下件
        this.saveData.partList = arr1;
        //附加项目
        this.saveData.addList = arr;

        this.saveData = Object.assign(this.saveData, this.saveData1);

        this.saveData = Object.assign(this.saveData, this.saveData2);

        this.saveData = Object.assign(this.saveData, this.saveData3);

        console.log(this.saveData);
        this.saveData.authId = this.rowData.authId;

        this.saveData.partId = this.partId;
        this.saveData.supId = this.supId;
        this.saveData.supCode = this.supCode;
        this.saveData.labourAmount = this.labourAmount;
        this.saveData.partAmount = this.partAmount;
        this.saveData.modelId = this.modelId;
        this.saveData.modelCode = this.modelCode;
        this.saveData.faId = this.faId; //故障现象主键
        this.saveData.frId = this.frId; //故障原因主键
        this.saveData.outId = this.outId;
        this.saveData.isDeleted = this.isDeleted;
        this.saveData.outCode = this.outCode;
        //判断是保存还是提交 默认0 提交1 作废2
        if (this.saveFlag == 1) {
          this.saveData.authStatus = 55031002;
        } else if (this.saveFlag == 2) {
          this.saveData.authStatus = 55031006;
        } else {
          this.saveData.authStatus = 55031001;
        }
        //保存前格式化时间类型
        //销售日期
        this.saveData.saleDate = moment(this.saveData.saleDate).format('YYYY-MM-DD HH:mm:ss');
        //保修起始日期
        this.saveData.repairBeginDate = moment(this.saveData.repairBeginDate).format('YYYY-MM-DD HH:mm:ss');
        //保修起始日期
        this.saveData.repairEndDate = moment(this.saveData.repairEndDate).format('YYYY-MM-DD HH:mm:ss');
        //维修开始时间
        this.saveData.serviceBeginDate = moment(this.saveData.serviceBeginDate).format('YYYY-MM-DD HH:mm:ss');
        //维修结束时间
        this.saveData.serviceEndDate = moment(this.saveData.serviceEndDate).format('YYYY-MM-DD HH:mm:ss');
        //自费配件销售日期
        // this.saveData.selfSdate = moment(this.saveData.selfSdate).format('YYYY-MM-DD HH:mm:ss');
        //生产日期
        this.saveData.prodDate = moment(this.saveData.prodDate).format('YYYY-MM-DD HH:mm:ss');

        //编辑的保存
        let res = await editSave(this.saveData);

        if (res.resultCode === 200) {
          this.closeDialog('refresh');
          return this.$notify.success({ title: '提示信息', message: '保存成功' });
          this.$emit('save');
        } else {
          this.$notify.error({ title: '提示信息', message: res.errMsg || '保存失败!' });
          this.closeDialog();
        }
      },
      //维修项目列表新增
      RepairItemListadd() {
        this.RepairItemListaddflag = true;
      },
      //配件换上件列表
      partTakeOnadd() {
        this.PartTakeOnlistaddflag = true;
      },
      PartTakeOnlistadd() {
        this.PartTakeOnlistaddflag = true;
      },
      //附加项目列表
      appendItemadd() {
        this.appendItemlistaddflag = true;
      },
      //救援单
      // jiuyuandanClose() {
      //   this.jiuyuandanFlag = false;
      // },
      // jiuyuandanSave(obj) {
      //   this.outId = obj[0].outId;
      //   //救援单返显
      //   this.formList1.map(x => {
      //     if ('outNo' == x.fieldName) {
      //       x.initialValue = obj[0].outCode; //救援号返显
      //     }
      //   });
      //
      //   this.jiuyuandanFlag = false;
      // },
      // selectoutNo() {
      //   this.jiuyuandanFlag = true;
      // },
      async  selectVinSave(obj) {
        if(this.rowDate.vin){
          //如果传进来的vin跟原来的vin不相同就清空table
          if(this.rowDate.vin!== obj[0].VIN){
            let arry = this.$refs.partTakeOntable.$refs.pageTable.list;
            this.$refs.partTakeOntable.$refs.pageTable.EXECUTE_DELETE(arry);
            this.feiyongformList.map(x => {
              if ('partAmount' == x.fieldName) {
                x.initialValue = 0;
                this.partAmountsumz=0;
                this.sumAmount();
              }
            });
          }
        }
        // this.menus[1].params.vin = obj[0].VIN;
        // this.menus[2].params.vin = obj[0].VIN;
        // this.menus[4].params.vin = obj[0].VIN;
        this.rowDate = obj[0];
        this.rowDate.roNo='';
        //页面上是车型名称  下面这两个是给后台传车型代码和车型id  （MODEL对应的是车型id）
        console.log(obj);
        this.modelCode = obj[0].MODEL_CODE;
        this.modelId = obj[0].MODEL;
        this.powertype = obj[0].POWER_TYPE;
        // let res = await translateByVinAndModelCode({vin:obj[0].VIN,modelCode: obj[0].MODEL_CODE,customerType: obj[0].BUSINESS_KIND});
        this.rowDate.vin= obj[0].VIN;
        let wxLog = await getRoLogList({vin:obj[0].VIN,current:1,limit:100,currentPage:1,pageNum:1,pageSize: 100,size: 100});
        if(wxLog.data.rows.length>=2){
          obj[0].lastDrive = wxLog.data.rows[wxLog.data.rows.length-2].IN_MILEAGE;
        }else{
          obj[0].lastDrive = 0
        }
        this.formList.map(x => {
          if ('vin' == x.fieldName) {
            x.initialValue = obj[0].VIN; //vin
          }
          if ('licenseNo' == x.fieldName) {
            x.initialValue = obj[0].LICENSE; //车牌号
          }
          if ('seriesName' == x.fieldName) {
            x.initialValue = obj[0].SERIES_NAME; //车型名称
          }
          if ('modelName' == x.fieldName) {
            x.initialValue = obj[0].MODEL_NAME; //车型名称
          }

          if ('saleDate' == x.fieldName) {
            x.initialValue = obj[0].SALES_DATE==""?null:moment(obj[0].SALES_DATE).format('YYYY-MM-DD'); //销售日期
          }

          // if ('repairBeginDate' == x.fieldName) {
          //   x.initialValue = obj[0].WRT_BEGIN_DATE==""?null:moment(obj[0].WRT_BEGIN_DATE).format('YYYY-MM-DD'); //保修起始日期
          // }

          if ('repairEndDate' == x.fieldName) {
            x.initialValue = obj[0].WRT_END_DATE==""?null:moment(obj[0].WRT_END_DATE).format('YYYY-MM-DD'); //保修起始日期
          }
          //
          // if ('serviceBeginDate' == x.fieldName) {
          //   x.initialValue = obj[0].serviceBeginDate; //维修开始时间
          // }
          // if ('serviceEndDate' == x.fieldName) {
          //   //发动机号
          //   x.initialValue = obj[0].serviceEndDate; //维修结束时间
          // }
          if ('driveMile' == x.fieldName) {
            x.initialValue = obj[0].MILEAGE; //行驶里程
          }
          if ('engineNo' == x.fieldName) {
            x.initialValue = obj[0].ENGINE_NO; //电机号
          }
          if ('customerName' == x.fieldName) {
            //车主姓名
            x.initialValue = obj[0].OWNER_NAME;
          }
          if ('customerPhone' == x.fieldName) {
            //车主手机号
            x.initialValue = obj[0].MOBILE;
          }  //提报人
          if ('applyName' == x.fieldName) {
            x.initialValue = obj[0].applyName;
          } //联系方式
          if ('applyPhone' == x.fieldName) {
            x.initialValue = obj[0].applyPhone;
          } //车辆用途
          if ('useType' == x.fieldName) {
            x.initialValue = obj[0].VEHICLE_PURPOSE;
          }
          //用户属性
          if ('customerType' == x.fieldName) {
            x.initialValue = obj[0].BUSINESS_KIND;
          }
          //送修人姓名
          if ('deliverer' == x.fieldName) {
            x.initialValue = obj[0].DELIVERER;
          }
          //送修人手机号
          if ('delivererMobile' == x.fieldName) {
            x.initialValue = obj[0].DELIVERER_MOBILE;
          }
          if ('lastDrive' == x.fieldName) {
            x.initialValue = obj[0].lastDrive;
          }
        });
        this.vinSelect = false;
        this.fetchParams = { ...this.fetchParams };

      },
      //vin
      vinClose() {
        this.vinSelect = false;
      },
      //维修工单
      repairOrderClose() {
        this.repairOrder = false;
      },
      repairOrderSave(obj) {
        this.modelCode = obj[0].modelCode;
        this.modelId = obj[0].modelId;
        console.log(888888888);
        // console.log(obj);
        console.log(888888888);
        this.formList.map(x => {
          if ('roNo' == x.fieldName) {
            x.initialValue = obj[0].roNo; //维修工单号返显
          }
          if ('prodDate' == x.fieldName) {
            x.initialValue = obj[0].prodDate; //生产日期
          }
          if ('authNo' == x.fieldName) {
            x.initialValue = obj[0].authNo; //预授权单号
          }
          if ('vin' == x.fieldName) {
            x.initialValue = obj[0].vin; //vin
          }
          if ('licenseNo' == x.fieldName) {
            x.initialValue = obj[0].licenseNo; //车牌号
          }
          if ('modelName' == x.fieldName) {
            x.initialValue = obj[0].modelName; //车型名称
          }

          if ('saleDate' == x.fieldName) {
            x.initialValue = obj[0].saleDate; //销售日期
          }

          if ('repairBeginDate' == x.fieldName) {
            x.initialValue = obj[0].repairBeginDate; //保修起始日期
          }

          if ('repairEndDate' == x.fieldName) {
            x.initialValue = obj[0].repairEndDate; //保修截止日期
          }

          if ('serviceBeginDate' == x.fieldName) {
            x.initialValue = obj[0].serviceBeginDate; //维修开始时间
          }
          if ('serviceEndDate' == x.fieldName) {
            //发动机号
            x.initialValue = obj[0].serviceEndDate; //维修结束时间
          }
          if ('driveMile' == x.fieldName) {
            x.initialValue = obj[0].driveMile; //行驶里程
          }
          if ('engineNo' == x.fieldName) {
            x.initialValue = obj[0].engineNo; //电机号
          }
          if ('customerName' == x.fieldName) {
            //车主姓名
            x.initialValue = obj[0].customerName;
          }
          if ('customerPhone' == x.fieldName) {
            //车主手机号
            x.initialValue = obj[0].customerPhone;
          } //送修人姓名
          if ('serviceName' == x.fieldName) {
            x.initialValue = obj[0].serviceName;
          }
          //送修人手机号
          if ('servicePhone' == x.fieldName) {
            x.initialValue = obj[0].servicePhone;
          } //提报人
          if ('applyName' == x.fieldName) {
            x.initialValue = obj[0].applyName;
          } //联系方式
          if ('applyPhone' == x.fieldName) {
            x.initialValue = obj[0].applyPhone;
          } //车辆用途
          if ('useType' == x.fieldName) {
            x.initialValue = obj[0].useType;
          } //用户属性
          if ('customerType' == x.fieldName) {
            x.initialValue = obj[0].customerType;
          }
          //是否特殊车辆
          if ('isSpecial' == x.fieldName) {
            x.initialValue = obj[0].isSpecial;
          }
        });
        this.weixiugongdan = false;
        this.fetchParams = { ...this.fetchParams };
      },
      //主损件
      mainDamagePartClose() {
        this.zhusunjian = false;
      },
      mainDamagePartSave(obj) {
        this.partId = obj[0].partId;
        this.formList1.map(x => {
          if ('partCode' == x.fieldName) {
            x.initialValue = obj[0].partCode; //主损件返显
          }
          if ('partName' == x.fieldName) {
            x.initialValue = obj[0].partName; //主损件返显
          }

        });

        this.zhusunjian = false;
        this.fetchParams = { ...this.fetchParams };
      },
      //故障现象
      faultAppearClose() {
        this.faultAppear = false;
      },
      faultAppearSave(obj) {
        this.faId = obj[0].faultId;
        this.formList1.map(x => {
          if ('faultCode' == x.fieldName) {
            x.initialValue = obj[0].faultCode; //故障现象代码返显
          }
          if ('faultName' == x.fieldName) {
            x.initialValue = obj[0].faultName; //故障现象名称返显
          }
          // if ('faultAppear' == x.fieldName) {
          //   x.initialValue = obj[0].faultName; //故障现象名称返显
          // }
          // if ('sysCode1' == x.fieldName) {
          //   x.initialValue = obj[0].sysCode1; //一级代码
          // }
          // if ('sysName1' == x.fieldName) {
          //   x.initialValue = obj[0].sysName1; //一级名称
          // }
          // if ('sysCode2' == x.fieldName) {
          //   x.initialValue = obj[0].sysCode2; //二级代码
          // }
          // if ('sysName2' == x.fieldName) {
          //   x.initialValue = obj[0].sysName2; //二级名称
          // }
          // if ('sysCode3' == x.fieldName) {
          //   x.initialValue = obj[0].sysCode3; //三级代码
          // }
          // if ('sysName3' == x.fieldName) {
          //   x.initialValue = obj[0].sysName3; //三级名称
          // }
          if ('sysCode4' == x.fieldName) {
            x.initialValue = obj[0].sysCode4; //代码
          }
          if ('sysName4' == x.fieldName) {
            x.initialValue = obj[0].sysName4; //名称
          }
          if ('sysCode' == x.fieldName) {
            x.initialValue = obj[0].sysCode; //故障代码
          }
          if ('faultAppera' == x.fieldName) {
            x.initialValue = obj[0].faultAppera; //故障现象
          }
        });

        this.faultAppear = false;
        this.fetchParams = { ...this.fetchParams };
      },
      //故障原因
      faultReasonClose() {
        this.faultReason = false;
      },
      faultReasonSave(obj) {
        this.frId = obj[0].frId;
        this.formList1.map(x => {
          if ('frCode' == x.fieldName) {
            x.initialValue = obj[0].frCode; //故障原因代码返显
          }
          if ('frName' == x.fieldName) {
            x.initialValue = obj[0].frName; //故障原因描述返显
          }
        });

        this.faultReason = false;
        this.fetchParams = { ...this.fetchParams };
      },
      //自费工单
      // zifeigongdanClose() {
      //   this.zifeigongdanFlag = false;
      // },
      // zifeigongdanSave(obj) {
      //   this.selfNo = obj[0].selfNo;
      //   this.formList1.map(x => {
      //     if ('selfNo' == x.fieldName) {
      //       x.initialValue = obj[0].selfNo; //主损件号返显
      //     }
      //     if ('selfSdate' == x.fieldName) {
      //       x.initialValue = obj[0].selfSdate; //自费配件销售日期返显
      //     }
      //     if ('selfMile' == x.fieldName) {
      //       x.initialValue = obj[0].selfMile; //自费配件销售里程返显
      //     }
          // if ('selfUseHours' == x.fieldName) {
          //   x.initialValue = obj[0].selfUseHours; //自费配件使用时长返显
          // }
          // if ('selfUseMile' == x.fieldName) {
          //   x.initialValue = obj[0].selfUseMile; //自费配件使用里程返显
          // }
          // if ('ncvcertnon' == x.fieldName) {
          //   x.initialValue = obj[0].certificateNo; //新车证件号
          // }
          // if ('ncvmobilen' == x.fieldName) {
          //   x.initialValue = obj.vtel; //客户电话
          // }
          // if ('ncvvinn' == x.fieldName) {
          //   x.initialValue = obj.vin; //vin
          // }
          // if ('ncvseriescoden' == x.fieldName) {
          //   x.initialValue = obj.seriesCode; //系列
          //   this.seriesCode = obj.seriesName;
          // }
          // if ('ncvseriesname' == x.fieldName) {
          //   x.initialValue = obj.seriesName; //车系名称
          //   this.seriesCode = obj.seriesName;
          // }

          // if ('ncvcartypecoden' == x.fieldName) {
          //   x.initialValue = obj.modelCode; //车型
          // }

          // if ('ncvcartypename' == x.fieldName) {
          //   x.initialValue = obj.salesModelName; //车型名称
          // }

          // if ('ncvbrandcoden' == x.fieldName) {
          //   x.initialValue = obj.brandCode; //品牌代码
          // }
          // if ('vengineanon' == x.fieldName) {
          //   //发动机号
          //   x.initialValue = obj.engineNo; //品牌代码
          // }
          // if ('vcertificateType' == x.fieldName) {
          //   x.initialValue = obj.vcertificateType; // this.createDictText(obj.vcertificateType,'1508', 1)
          // }
          // if ('ncvdidn' == x.fieldName) {
          //   x.initialValue = obj.ownerCode; //新车经销商
          // }
          // if ('ncvdidname' == x.fieldName) {
          //   x.initialValue = obj.dealerName; //新车经销商名称
          // }
          // if ('ncdcreate' == x.fieldName) {
          //   //出库日期
          //   x.initialValue = obj.aakDate; //aak
          // }
          // // if ('ncdnewinvoicen' == x.fieldName) {
          // //   //发票日期
          // //   x.initialValue = obj.invoiceDate;
          // // }
          // if ('dinvoicesum' == x.fieldName) {
          //   x.initialValue = obj.invoiceAmount;
          // }

          // if ('legalFlag' == x.fieldName) {
          //   x.initialValue = ''; /*清空本人/法人置换*/
          //   this.setOldData('N');
          // }
      //   });
      //
      //   this.zifeigongdanFlag = false;
      //   this.fetchParams = { ...this.fetchParams };
      // }, //维修项目
      RepairItemListClose() {
        this.RepairItemListaddflag = false;
      },
      RepairItemListSave(val) {
        console.log(val);
        this.visibleAdd = false;
        this.selectedRows = val;
        this.$refs.repairItemtable.$refs.pageTable.EXECUTE_INSERT(val);


        let sumweixiufeiyong = 0;
        this.$refs.repairItemtable.$refs.pageTable.list.map(x => {
          sumweixiufeiyong += Number(x.cmsClaimAmount);
        });
        this.feiyongformList.map(x => {
          if ('labourAmount' == x.fieldName) {
            x.initialValue = Number(sumweixiufeiyong);
          }
        });
        this.sumweixiufeiyongz=sumweixiufeiyong;
        this.sumAmount();
        this.RepairItemListaddflag = false;
        this.fetchParams = { ...this.fetchParams };
      },
      //配件换上件
      partTakeOnClose() {
        this.PartTakeOnlistaddflag = false;
      },
      appendItemCloseSave() {
        this.appendItemCloselistaddflag = false;
        this.fetchParams = { ...this.fetchParams };
      },
      //附加项目
      appendItemClose() {
        this.appendItemlistaddflag = false;
      },
      appendItemSave(val) {
        this.$refs.appendItemtable.$refs.pageTable.EXECUTE_INSERT(val);

        let sumfujiafeiyong = 0;
        this.$refs.appendItemtable.$refs.pageTable.list.map(x => {
          sumfujiafeiyong += Number(x.addAmount);
        });
        this.feiyongformList.map(x => {
          if ('addAmount' == x.fieldName) {
            x.initialValue = Number(sumfujiafeiyong);
          }
        });
        this.sumfujiafeiyongz=sumfujiafeiyong;
        this.sumAmount();
        this.appendItemlistaddflag = false;
        this.fetchParams = { ...this.fetchParams };
      },

      //配件换上件
      partTakeOnSave(val) {
        console.log(val);
        this.$refs.partTakeOntable.$refs.pageTable.EXECUTE_INSERT(val);

        let partAmountsum = 0;
        this.$refs.partTakeOntable.$refs.pageTable.list.map(x => {
          this.sumAmountsum += Number(x.cmsClaimPrice);
          partAmountsum += Number(x.cmsClaimPrice);
        });
        this.feiyongformList.map(x => {
          if ('partAmount' == x.fieldName) {
            x.initialValue = partAmountsum;
          }
        });
        this.partAmountsumz=partAmountsum;
        this.sumAmount();

        // this.$refs.partTakeOntable.$refs.pageTable.list.map(x => {
        //   console.log(x.cmsClaimPrice);
        //   this.sumPeiJianFeiYong += Number(x.cmsClaimPrice);
        // });
        // this.feiyongformList.map(x => {
        //   if ('sumCmsClaimPrice' == x.fieldName) {
        //     x.initialValue = this.sumPeiJianFeiYong;
        //   }
        // });
        this.peijianhuanshangjianlistaddflag = false;
        this.fetchParams = { ...this.fetchParams };
      },
      //作废
      async zuofei() {
        this.saveFlag = 2;
        this.saveDialog();
      }, //提交
      async submit() {
        this.saveFlag = 1;
        this.saveDialog();
        // const res = await zuofeiFun({ ids: rowData.authId, status: '55031002' });
      },
      //取消操作
      closeDialog() {
        this.$emit('close', { visible: false, data: this.selectedRows, type: 'close' });
      },
      chooseOrderNo() {
        this.visible = true;
      }, //维修工单号选择
      selectVin() {
        this.vinSelect = true;
      },
      //维修工单号选择
      selectRono() {
        this.repairOrder = true;
      },
      selectpartCode() {
        this.mainDamagePart = true;
      },
      selectfaultCode() {
        this.faultAppear = true;
      },
      selectfaultReason() {
        this.faultReason = true;
      },
      // selectselfNo() {
      //   this.zifeigongdanFlag = true;
      // },
      add() {},
      createFormList() {
        return [
          {
            type: 'INPUT',
            label: '预授权单号',
            fieldName: 'authNo',
            disabled: true
          },
          {
            type: 'INPUT',
            label: 'VIN',
            fieldName: 'vin',
            initialValue: '',
            disabled: true,
            readonly: true,
            placeholder: '请输入VIN...',
            rules: [{ required: false, message: '请输入VIN...', trigger: 'blur' }],
            unitRender: p => {
              return (
                <div>
                  <multiuse-button icon="el-icon-search" onClick={() => this.selectVin()} />
                </div>
              );
            }
          },
          {
            type: 'INPUT',
            label: '车牌号',
            fieldName: 'licenseNo',
            disabled: true,
            placeholder: '请输入车牌号...'
          },
          {
            type: 'INPUT',
            label: '维修工单号',
            fieldName: 'roNo',
            initialValue: '',
            disabled: true,
            readonly: true,
            placeholder: '请输入维修工单号...',
            rules: [{ required: false, message: '请填维修工单号', trigger: 'blur' }],
            unitRender: p => {
              return (
                <div>
                  <multiuse-button icon="el-icon-search" onClick={() => this.selectRono()} />
                </div>
              );
            }
          },
          // {
          //   type: 'SELECT',
          //   label: '预授权状态',
          //   fieldName: 'authStatus',
          //   disabled: true,
          //   itemList:[],
          //   placeholder: '请输入标题名称...'
          // },
          // {
          //   type: 'INPUT',
          //   label: 'VIN',
          //   fieldName: 'vin',
          //   disabled: true,
          //   placeholder: '请输入标题名称...'
          // },
          // RO_CREATE_DATE
          {
            type: 'INPUT',
            label: '开单日期',
            fieldName: 'roCreateDate',
            placeholder: '请输入开单日期...',
            readonly: true, // 只读
            disabled: true,
          },
          {
            type: 'INPUT',
            label: '车系名称',
            fieldName: 'seriesName',
            disabled: true,
            placeholder: '请输入车系名称...'
          },
          {
            type: 'INPUT',
            label: '车型名称',
            fieldName: 'modelName',
            disabled: true,
            placeholder: '请输入车型名称...'
          },
          {
            type: 'INPUT',
            label: '销售日期',
            fieldName: 'saleDate',
            placeholder: '请输入销售日期...',
            readonly: true, // 只读
            disabled: true,
          },
          // {
          //   type: 'INPUT',
          //   label: '保修起始日期',
          //   fieldName: 'repairBeginDate',
          //   placeholder: '请输入标题名称...',
          //   readonly: true, // 只读
          //   disabled: true,
          // },
          {
            type: 'INPUT',
            label: '保修截止日期',
            fieldName: 'repairEndDate',
            disabled: true,
            placeholder: '请输入标题名称...'
          },
          // {
          //   type: 'DATE',
          //   label: '维修开始时间',
          //   fieldName: 'serviceBeginDate',
          //   placeholder: '请输入标题名称...',
          //   valueFormat:'yyyy-MM-DD HH:mm:ss',
          //   readonly: true, // 只读
          //   disabled: true,
          // },
          // {
          //   type: 'DATE',
          //   label: '维修结束时间',
          //   fieldName: 'serviceEndDate',
          //   placeholder: '请输入标题名称...',
          //   valueFormat:'yyyy-MM-DD HH:mm:ss',
          //   readonly: true, // 只读
          //   disabled: true,
          // },

          {
            type: 'INPUT',
            label: '电机号',
            fieldName: 'engineNo',
            disabled: true,
            placeholder: '请输入标题名称...'
          },
          // {
          //   type: 'INPUT',
          //   label: '生产日期',
          //   fieldName: 'prodDate',
          //   disabled: true,
          //   placeholder: '请输入生产日期...'
          // },

          // {
          //   type: 'SELECT',
          //   label: '是否特殊车辆',
          //   fieldName: 'isSpecial',
          //   disabled: true,
          //   initialValue: undefined,
          //   itemList: this.createDictList('5532')
          // },
          {
            type: 'INPUT',
            label: '车主姓名',
            fieldName: 'customerName',
            disabled: true,
            placeholder: '请输入标题名称...'
          },
          {
            type: 'INPUT',
            label: '车主手机号',
            fieldName: 'customerPhone',
            disabled: true,
            placeholder: '请输入标题名称...'
          },
          {
            type: 'SELECT',
            label: '用户属性',
            fieldName: 'customerType',
            disabled: true,
            initialValue: undefined,
            itemList: this.createDictList('5584')
          },
          {
            type: 'INPUT',
            label: '车辆用途',
            style: { minWidth: '200px' },
            disabled: true,
            fieldName: 'useType',
          },

          // {
          //   type: 'INPUT',
          //   label: '上次维修里程',
          //   fieldName: 'lastDrive',
          //   disabled: true,
          //   initialValue: '',
          //   unitRender: () => {
          //     return <span>(KM)</span>;
          //   },
          // },
          {
            type: 'INPUT',
            label: '行驶里程',
            disabled: true,
            unitRender: () => {
              return <span>(KM)</span>;
            },
            rules: [{ required: false, message: '请填行驶里程', trigger: 'blur' }, { pattern: /[\d\.]+/g, message: '请输入数字', trigger: 'blur' }],
            fieldName: 'driveMile',
            placeholder: '请输入行驶里程...',
            change:  val => {
              if(Number(val)<Number(this.formList.find(x => x.fieldName == 'lastDrive').initialValue)){
                this.formList.find(x => x.fieldName == 'driveMile').initialValue =null;
                return this.$notify.success({title: '提示信息', message: '里程数小于上次行驶里程'});
              }
            }
          },
          {
            type: 'INPUT',
            label: '送修人姓名',
            fieldName: 'deliverer',
            disabled: true,
            // rules: [{ required: false, message: '送修人姓名', trigger: 'blur' }],
            placeholder: '请输入送修人姓名...'
          },
          {
            type: 'INPUT',
            label: '送修人手机号',
            fieldName: 'delivererMobile',
            disabled: true,
            // rules: [{ required: false, message: '送修人手机号', trigger: 'blur' },{pattern:/^[1][3,4,5,6,7,8,9][0-9]{9}$/,message:'请填写正确的手机号格式',trigger: 'blur'}],
            placeholder: '请输入送修人手机号...'
          },
          {
            type: 'INPUT',
            label: '提报人',
            fieldName: 'serviceName',
            placeholder: '提报人',
            disabled: true
          },
          {
            type: 'INPUT',
            label: '联系方式',
            disabled: true,
            fieldName: 'servicePhone',
            placeholder: '联系方式',
          },
          {
            type: 'INPUT',
            label: '电池编号',
            disabled: true,
            fieldName: 'batteryNo',
            rules: [{ required: false, message: '请输入电池编号...', trigger: 'blur' }],
            placeholder: '请输入电池编号...'
          },
        ];
      },
      createFormList1() {
        return [
          { type: 'SELECT', label: '预授权类型', fieldName: 'authType', placeholder: '请选择',  disabled: true, initialValue: '', itemList: [] },
          { type: 'SELECT', label: '常规预授权分类', fieldName: 'authSub',
            placeholder: '请选择常规预授权分类...',
            hidden: true,
            disabled: true,
            filterable: true,
            rules: [{ required: true, message: '请选择常规预授权分类...', trigger: 'blur' }],
          },
          {
            type: 'INPUT',
            label: '主损件',
            fieldName: 'partCode',
            readonly: true,
            disabled: true,
            placeholder: '请选择主损件...',
            rules: [{ required: false, message: '请选择主损件...', trigger: 'blur' }],
            unitRender: p => {
              return (
                <div>
                  <multiuse-button icon="el-icon-search" onClick={() => this.selectpartCode()} />
                </div>
              );
            }
          },
          {
            type: 'INPUT',
            label: '主损件名称',
            fieldName: 'partName',
            disabled: true,
            placeholder: '请输入主损件名称...'
          },
          { type: 'INPUT',
            label: '供应商',
            fieldName: 'supName',
            placeholder: '请选择供应商...',
            disabled: true,
            rules: [{ required: false, message: '请输入供应商', trigger: 'blur' }],
            unitRender: p => {
              return (
                <div>
                  <multiuse-button icon="el-icon-search" onClick={() => this.selectSuppliersCode()} />
                </div>
              );
            }
          },
          { type: 'INPUT',
            label: '责任商',
            fieldName: 'responsiblePerson',
            // hidden: true,
            disabled: true,
            placeholder: '请输入责任商...',
          },
          { type: 'INPUT',
            label: '赔付原因',
            fieldName: 'payReason',
            // hidden: true,
            disabled: true,
            placeholder: '请输入赔付原因...',
          },
          {
            type: 'INPUT',
            label: '故障现象',
            fieldName: 'sysName4',
            disabled: true,
            placeholder: '请选择故障现象...',
            rules: [{ required: false, message: '请选择故障现象...', trigger: 'blur' }],
            unitRender: p => {
              return (
                <div>
                  <multiuse-button icon="el-icon-search" onClick={() => this.selectfaultCode()} />
                </div>
              );
            }
          },
          // {
          //   type: 'INPUT',
          //   label: '故障现象描述',
          //   fieldName: 'faultName',
          //   disabled: true,
          //   placeholder: '请输入...'
          // },
          //   {
          //     type: 'INPUT',
          //     label: '一级代码',
          //     fieldName: 'sysCode1',
          //     disabled: true,
          //     placeholder: '请输入...'
          //   },
          //
          // {
          //   type: 'SELECT',
          //   label: '一级名称',
          //   fieldName: 'sysName1',
          //   placeholder: '请选择...',
          //   disabled: false,
          //   itemList: [],
          //   rules: [{required: true, message: '请选择一级名称...', trigger: 'change'}],
          //   change: val => {
          //       this.changeSysName1Select(val);
          //       let sysName1 = this.formList1.find(x => x.fieldName == 'sysCode1').initialValue
          //       let list = this.formList1.find(x => x.fieldName === 'sysName1').itemList;
          //       console.log(val,"ybbb");
          //       this.formList1.find(x => x.fieldName == 'sysCode1').initialValue =list.find(x => x.value === val).value;
          //       console.log("sppp");
          //   }
          // },
          //   {
          //     type: 'INPUT',
          //     label: '二级代码',
          //     fieldName: 'sysCode2',
          //     disabled: true,
          //     placeholder: '请输入...'
          //   },
          //
          // {
          //   type: 'SELECT',
          //   label: '二级名称',
          //   fieldName: 'sysName2',
          //   placeholder: '请选择...',
          //   disabled: false,
          //   itemList: [],
          //   rules: [{required: true, message: '请选择二级名称...', trigger: 'change'}],
          //   change: val => {
          //       let list1 = this.formList1.find(x => x.fieldName === 'sysName2').itemList;
          //       this.formList1.find(x => x.fieldName == 'sysCode2').initialValue =list1.find(x => x.value === val).value;
          //       this.changeSysName2Select(val);
          //   }
          // },
          //   {
          //     type: 'INPUT',
          //     label: '三级代码',
          //     fieldName: 'sysCode3',
          //     disabled: true,
          //     placeholder: '请输入...'
          //   },
          //
          // {
          //   type: 'SELECT',
          //   label: '三级名称',
          //   fieldName: 'sysName3',
          //   placeholder: '请输入...',
          //   disabled: false,
          //   itemList: [],
          //   rules: [{required: true, message: '请选择三级名称...', trigger: 'change'}],
          //   change: val => {
          //       let list2 = this.formList1.find(x => x.fieldName === 'sysName3').itemList;
          //       this.formList1.find(x => x.fieldName == 'sysCode3').initialValue =list2.find(x => x.value === val).value;
          //       this.changeSysName3Select(val);
          //   }
          // },

          //   {
          //     type: 'INPUT',
          //     label: '故障现象',
          //     fieldName: 'sysCode4',
          //     disabled: true,
          //     placeholder: '请输入...'
          //   },
          // {
          //   type: 'SELECT',
          //   label: '故障描述',
          //   fieldName: 'sysName4',
          //   placeholder: '请输入...',
          //   disabled: false,
          //   itemList: [],
          //   rules: [{required: true, message: '请选择故障描述...', trigger: 'change'}],
          //   change: val => {
          //       let list3 = this.formList1.find(x => x.fieldName === 'sysName4').itemList;
          //       this.formList1.find(x => x.fieldName == 'sysCode4').initialValue =list3.find(x => x.value === val).value;
          //       this.getFaultNameSelect(val);
          //   }
          // },
          {
            type: 'INPUT',
            label: '故障原因',
            fieldName: 'frName',
            disabled: true,
            placeholder: '请选择故障原因...',
            rules: [{ required: false, message: '请选择故障原因...', trigger: 'blur' }],
            unitRender: p => {
              return (
                <div>
                  <multiuse-button icon="el-icon-search" onClick={() => this.selectfaultReason()} />
                </div>
              );
            }
          },
          // {
          //   type: 'INPUT',
          //   label: '原因代码名称',
          //   disabled: true,
          //   fieldName: 'frName',
          //   placeholder: '请输入...'
          // },

          // {
          //   type: 'INPUT',
          //   label: '外出救援单号',
          //   // fieldName: 'outNo',
          //   fieldName: 'outCode',
          //   readonly: true,
          //   placeholder: '请输入救援单号...',
          //   unitRender: p => {
          //     return (
          //       <div>
          //       <multiuse-button icon="el-icon-search" onClick={() => this.selectoutNo()} />
          //     </div>
          //   );
          //   }
          // },
          // {
          //   type: 'INPUT',
          //   label: '自费工单选择',
          //   fieldName: 'selfNo',
          //   hidden: true,
          //   readonly: true,
          //   placeholder: '请输入...',
          //   rules: [{ required: true, message: '请选择自费工单', trigger: 'blur' }],
          //   unitRender: p => {
          //     return (
          //       <div>
          //       <multiuse-button icon="el-icon-search" onClick={() => this.selectselfNo()} />
          //     </div>
          //   );
          //   }
          // },
          // {
          //   type: 'DATE',
          //   label: '自费配件销售日期',
          //   fieldName: 'selfSdate',
          //   disabled: true,
          //   hidden: true,
          //   valueFormat:'yyyy-MM-DD',
          //   placeholder: '请输入...'
          // },
          // {
          //   type: 'INPUT',
          //   label: '自费配件销售里程',
          //   fieldName: 'selfMile',
          //   disabled: true,
          //   hidden: true,
          //   placeholder: '请输入...'
          // },
          // {
          //   type: 'INPUT',
          //   label: '自费配件使用时长',
          //   disabled: true,
          //   hidden: true,
          //   fieldName: 'selfUseHours',
          //   placeholder: '请输入...'
          // },
          // {
          //   type: 'INPUT',
          //   label: '自费配件使用里程',
          //   disabled: true,
          //   hidden: true,
          //   fieldName: 'selfUseMile',
          //   placeholder: '请输入...'
          // },
          {
            type: 'TEXT_AREA',
            label: '故障现象描述',
            fieldName: 'faultAppear',
            rules: [{ required: false, message: '请输入故障现象...', trigger: 'blur' }],
            placeholder: '请输入故障现象...',
            disabled: true,
            rows: 3,
            selfCols: 4 // 元素占据几行
          },
          {
            type: 'TEXT_AREA',
            label: '故障原因描述',
            fieldName: 'faultReason',
            rules: [{ required: false, message: '请输入故障原因...', trigger: 'blur' }],
            placeholder: '请输入故障原因...',
            rows: 3,
            disabled: true,
            selfCols: 4 // 元素占据几行
          },
          {
            type: 'TEXT_AREA',
            label: '维修方案描述',
            fieldName: 'cmsClaimPgm',
            rules: [{ required: false, message: '请输入维修方案...', trigger: 'blur' }],
            placeholder: '请输入维修方案...',
            disabled: true,
            rows: 3,
            selfCols: 4 // 元素占据几行
          },
          // {
          //   type: 'BREAK_SPACE',
          //   label: '附件'
          // },
          // {
          //   type: 'UPLOAD_IMG',
          //   label: 'VIN',
          //   fieldName: 'wayPicture',
          //   placeholder: '上传身份证...',
          //   selfCols: 1,
          //   rules: [{ required: true, message: '请上传身份证', trigger: 'change' }, { limit: 1, validator: this.validateFn, message: '请上传1张图片', trigger: 'change' }],
          //   upload: {
          //     actionUrl: '/api/file/oss/upload',
          //     fixedSize: [5, 3],
          //     limit: 1,
          //     isCalcHeight: true
          //   }, readonly: true,// 只读
          //   disabled: true, // 置会
          // },
          // {
          //   type: 'UPLOAD_IMG',
          //   label: '里程（仪表）',
          //   fieldName: 'wayPicture1',
          //   placeholder: '上传身份证...',
          //   selfCols: 1,
          //   rules: [{ required: true, message: '请上传身份证', trigger: 'change' }, { limit: 1, validator: this.validateFn, message: '请上传1张图片', trigger: 'change' }],
          //   upload: {
          //     actionUrl: '/api/file/oss/upload',
          //     fixedSize: [5, 3],
          //     limit: 1,
          //     isCalcHeight: true
          //   }, readonly: true,// 只读
          //   disabled: true, // 置会
          // },
          // {
          //   type: 'UPLOAD_IMG',
          //   label: '车牌（车头）',
          //   fieldName: 'wayPicture2',
          //   placeholder: '上传身份证...',
          //   offsetRightCols: 1,
          //   rules: [{ required: true, message: '请上传身份证', trigger: 'change' }, { limit: 1, validator: this.validateFn, message: '请上传1张图片', trigger: 'change' }],
          //   upload: {
          //     actionUrl: '/api/file/oss/upload',
          //     fixedSize: [5, 3],
          //     limit: 1,
          //     isCalcHeight: true
          //   }, readonly: true,// 只读
          //   disabled: true, // 置会
          // },
          // {
          //   type: 'UPLOAD_IMG',
          //   label: '行驶证',
          //   fieldName: 'wayPicture3',
          //   placeholder: '上传身份证...',
          //   rules: [{ required: true, message: '请上传身份证', trigger: 'change' }, { limit: 1, validator: this.validateFn, message: '请上传1张图片', trigger: 'change' }],
          //   upload: {
          //     actionUrl: '/api/file/oss/upload',
          //     fixedSize: [5, 3],
          //     limit: 1,
          //     isCalcHeight: true
          //   }, readonly: true,// 只读
          //   disabled: true, // 置会
          // },
          // {
          //   type: 'UPLOAD_IMG',
          //   label: '故障照片',
          //   fieldName: 'wayPicture4',
          //   placeholder: '上传身份证...',
          //   // rules: [{ required: true, message: '请上传身份证', trigger: 'change' }, { limit: 1, validator: this.validateFn, message: '请上传1张图片', trigger: 'change' }],
          //   upload: {
          //     actionUrl: '/api/file/oss/upload',
          //     fixedSize: [5, 3],
          //     limit: 1,
          //     isCalcHeight: true
          //   }, readonly: true,// 只读
          //   disabled: true, // 置会
          // },
          // {
          //   type: 'UPLOAD_IMG',
          //   label: '故障照片',
          //   fieldName: 'wayPicture5',
          //   placeholder: '上传身份证...',
          //   // rules: [{ required: true, message: '请上传身份证', trigger: 'change' }, { limit: 1, validator: this.validateFn, message: '请上传1张图片', trigger: 'change' }],
          //   upload: {
          //     actionUrl: '/api/file/oss/upload',
          //     fixedSize: [5, 3],
          //     limit: 1,
          //     isCalcHeight: true
          //   }, readonly: true,// 只读
          //   disabled: true, // 置会
          // }
        ];
      },
      createdTable() {
        return [
          {
            title: '序号',
            dataIndex: 'index',
            width: 70,
            fixed: 'left',
            sorter: true,
            render: props => {
              return <span>{props.row.index + 1}</span>;
            }
          },
          // {
          //   title: '操作',
          //   dataIndex: 'column-action',
          //   width: 90,
          //   render: (props, h) => {
          //     return (
          //       <div>
          //         <el-button size="mini" type="text" onClick={() => this.video(props.row)}>
          //           预览
          //         </el-button>
          //       </div>
          //     );
          //   }
          // },
          {
            title: '附件标题',
            dataIndex: 'title',
            showOverflowTooltip: true,
            render: p => {
              return (
                <a style="color:#bb0a30" href={p.row.fileUrl} target="_blank" download={p.row.title}>
                  {p.row.title}
                </a>
              );
            }
          },
          {
            title: '上传日期',
            dataIndex: 'createdAt'
          },
        ];
      },
      //维修项目列表
      creatHeader() {
        return [
          {
            title: '序号',
            dataIndex: 'index',
            width: 80,
            sorter: true,
            render: props => {
              return <span>{props.row.index + 1}</span>;
            }
          },
          { title: '维修项目代码', dataIndex: 'labourCode', sorter: true },
          { title: '维修项目名称', dataIndex: 'labourName', sorter: true },
          { title: '收费区分', dataIndex: 'cmsClaimType', sorter: true },
          { title: '标准工时', dataIndex: 'labourHours', sorter: true },
          { title: '索赔工时单价', dataIndex: 'cmsClaimPrice', sorter: true },
          { title: '索赔金额', dataIndex: 'cmsClaimAmount', sorter: true }
        ];
      },
      //配件换上件列表
      creatHeader1() {
        return [
          {
            title: '序号',
            dataIndex: 'index',
            width: 80,
            sorter: true,
            render: props => {
              return <span>{props.row.index + 1}</span>;
            }
          },
          { title: '配件代码', dataIndex: 'partCode', sorter: true },
          { title: '配件名称', dataIndex: 'partName', sorter: true },
          { title: '单位', dataIndex: 'partUnit', sorter: true },
          { title: '数量', dataIndex: 'partCount', sorter: true },
          { title: '索赔单价', dataIndex: 'cmsClaimPrice', sorter: true },
          { title: '索赔总价', dataIndex: 'cmsClaimAmount', sorter: true },
          // { title: '是否电池', dataIndex: 'ifEv', sorter: true },
          // { title: '电池编号', dataIndex: 'evNo', sorter: true }
        ];
      },
      //换下件
      columnspartTakeOffFn() {
        return [
          {
            title: '序号',
            dataIndex: 'index',
            width: 80,
            sorter: true,
            fixed: 'left',
            render: (props) => {
              return <span>{props.row.index + 1}</span>;
            },
          },
          // {
          //   title: '操作',
          //   dataIndex: 'column-action',
          //   width: 80,
          //   render: (props) => {
          //     return (
          //       <div style="text-align:center">
          //         <multiuse-button type="text" disabled={(this.flag)} onClick={() => this.delsFunXj(props.row)} >
          //           删除
          //         </multiuse-button>
          //       </div>
          //     );
          //   },
          // },
          { title: '配件代码', dataIndex: 'partCode', sorter: true },
          { title: '配件名称', dataIndex: 'partName', sorter: true },
          { title: '单位', dataIndex: 'partUnit', sorter: true },
          // { title: '剩余数量', dataIndex: 'lessCount', sorter: true },
          { title: '数量', dataIndex: 'partCount', editable: false,
            editType: 'number',
            // editRequired: true,
            editValidator:(val, row, callback) => {
              // this.$refs.table1.$refs.pageTable.list.map((x) => {
              //   if (row.partCode == x.partCode) {
              //    this.number = x.partCount
              //   }
              // });
              // if (row.partCount > this.number) {
              //   this.$notify.error({ title: '提示信息', message: '已超过换上件最大数量(' + this.number + ')' || '操作失败!' });
              //   row.partCount = 1
              // }else
              if(row.partCount<0){
                this.$notify.error({ title: '提示信息', message: '换下件最小数量为0' });
                row.partCount = 0
              }
            }

          },
          // { title: '配件回运类型', dataIndex: 'returnType', sorter: true, dictItems:[] },
          // { title: '配件代码', dataIndex: 'partId', hidden: true },
        ];
      },
      //附加项目列表
      columnsAppendItem1() {
        return [
          {
            title: '操作',
            dataIndex: 'column-action',
            width: 130,
            render: props => {
              return (
                <div style="text-align:center">
                  <multiuse-button type="text" onClick={() => this.editFile(props.row)} >
                    上传附件
                  </multiuse-button>
                </div>
              );
            }
          },
          { title: '附加项目代码', dataIndex: 'addCode', sorter: true },
          { title: '附加项目名称', dataIndex: 'addName', sorter: true },
          { title: '附加项目费用', dataIndex: 'addAmount', sorter: true },
          { title: '备注', dataIndex: 'addRemark', sorter: true }
        ];
      },
      //费用信息
      feiyongformList1() {
        return [
          {
            type: 'INPUT',
            label: '合计费用',
            fieldName: 'sumAmount',
            initialValue: 0,
            disabled: true,
            readonly: true // 只读
          },
          {
            type: 'INPUT',
            label: '工时费用',
            fieldName: 'labourAmount',
            initialValue: 0,
            disabled: true,
            readonly: true // 只读
          },
          {
            type: 'INPUT',
            label: '配件费用',
            fieldName: 'partAmount',
            initialValue: 0,
            disabled: true,
            readonly: true // 只读
          },
          {
            type: 'INPUT',
            label: '附加项目费用',
            fieldName: 'addAmount',
            initialValue: '',
            disabled: true,
            readonly: true // 只读
          }
        ];
      } /**维修项目删除方法 */,
      deleteFunweixiu(costItem) {
        this.$confirm('此操作将删除该数据, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        })
          .then(async () => {
            this.$notify({
              title: '提示信息',
              message: '删除成功',
              type: 'success'
            });
            this.$refs.repairItemtable.$refs.pageTable.EXECUTE_DELETE([costItem]);//cmsClaimAmount
            this.feiyongformList.map(x => {
              if ('labourAmount' == x.fieldName) {
                x.initialValue = this.sumweixiufeiyongz - Number(costItem.cmsClaimAmount);
                this.sumAmount();
              }
            });
          })
      } /**配件换上件删除方法 */,
      deleteFunshangjian(costItem) {
        this.$confirm('此操作将删除该数据, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        })
          .then(async () => {
            this.$notify({
              title: '提示信息',
              message: '删除成功',
              type: 'success'
            });
            this.$refs.partTakeOntable.$refs.pageTable.EXECUTE_DELETE([costItem]);
            this.feiyongformList.map(x => {
              if ('partAmount' == x.fieldName) {
                x.initialValue = this.partAmountsumz - Number(costItem.cmsClaimPrice);
                this.sumAmount();
              }
            });
          })
      }  /*附加项目删除方法 */,
      deleteFunfujia(costItem) {
        this.$confirm('此操作将删除该数据, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        })
          .then(async () => {
            this.$notify({
              title: '提示信息',
              message: '删除成功',
              type: 'success'
            });
            this.$refs.appendItemtable.$refs.pageTable.EXECUTE_DELETE([costItem]);
            this.feiyongformList.map(x => {
              if ('addAmount' == x.fieldName) {
                x.initialValue = this.sumfujiafeiyongz - Number(costItem.addAmount);
                this.sumAmount();
              }
            });
          })
      }
    }
  };
</script>

<style lang="less" scoped></style>
